package bt.sim.login;

import com.jfinal.plugin.activerecord.Model;
/**
 * User model.

将表结构放在此，消除记忆负担
mysql> desc t_user;
+----------+-------------+------+-----+---------+----------------+
| Field    | Type        | Null | Key | Default | Extra          |
+----------+-------------+------+-----+---------+----------------+
| id       | int(11)     | NO   | PRI | NULL    | auto_increment |
| userName | varchar(20) | YES  |     | NULL    |                |
| password | varchar(20) | YES  |     | NULL    |                |
+----------+-------------+------+-----+---------+----------------+

数据库字段名建议使用驼峰命名规则，便于与 java 代码保持一致，如字段名： userId
 */
public class User extends Model<User> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 所有 sql 与业务逻辑写在 Model 或 Service 中，不要写在 Controller 中，养成好习惯，有利于大型项目的开发与维护
	 */
	public static final User me = new User();
	
	public User findUser(User user) {
		String sql = "select * from t_user where userName = ? and password = ?";
		return findFirst(sql, user.get("userName"), user.get("password"));
	}
}
